package Java_2_58;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

//增强型for循环和普通for循环
public class TestForEach {
	public static void main(String[]args) {
		String[]stuArr= {"王云","刘静涛","南天华","雷静"};
		//传统for循环遍历
		for(int i=0;i<stuArr.length;i++) {
			System.out.println(stuArr[i]);
		}
		//增强型for循环遍历
		for(String stu:stuArr) {
			System.out.println(stu);
		}
		Set nameSet=new HashSet();
		nameSet.add("王云");
		nameSet.add("刘静涛");
		nameSet.add("南天华");
		nameSet.add("雷静");
		//迭代器遍历
		Iterator it =nameSet.iterator();
		while(it.hasNext()) {
			System.out.println(it.next());
		}
		//增强型for循环遍历
		for(Object stu2:nameSet) {
			System.out.println((String)stu2);
		}
	}
}
